//
//  DLCell.m
//  duilian
//
//  Created by shaojinkuang on 7/12/16.
//  Copyright © 2016 shaojinkuang. All rights reserved.
//

#import "DLCell.h"

#import "UIView+SDAutoLayout.h"
@implementation DLCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubViews];
    }
    return self;
}
- (void)setupSubViews {
    self.title = [UILabel new];
    //self.title.backgroundColor = [UIColor greenColor];
    //self.title.font = [UIFont fontWithName:@"JSouJingSu" size:20.0f];
    self.title.textAlignment = NSTextAlignmentCenter;
    
    self.selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.selectBtn setTitle:@"选择" forState:UIControlStateNormal];
    //[self.selectBtn setBackgroundColor:[UIColor redColor]];
    self.selectBtn.backgroundColor = [UIColor redColor];
    
    [self.contentView addSubview:self.title];
    [self.contentView addSubview:self.selectBtn];
    
    self.title.sd_layout.leftSpaceToView(self.contentView,0).topSpaceToView(self.contentView,0)
    .heightRatioToView(self.contentView,1).rightSpaceToView(self.contentView,0);
    
    self.selectBtn.sd_layout.rightSpaceToView(self.contentView,0).topSpaceToView(self.contentView,5)
    .bottomSpaceToView(self.contentView,5).widthIs(100);
    
    //添加btn的响应函数
    [self.selectBtn addTarget:self action:@selector(btnFunction:) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark - btn Function
- (IBAction)btnFunction:(id)sender {
    if (self.myBlock) {
        self.myBlock();
    }
}
@end
